<template>
    <div>
        <div class="book_title">
            <h1 align="center">未完成盘点任务</h1>
        </div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>系统中心</el-breadcrumb-item>
            <el-breadcrumb-item>未完成补货任务</el-breadcrumb-item>
        </el-breadcrumb>
        <hr>
        <br>
        <el-table
                :data="inventoryTask"
                height="250"
                border
                style="width: 100%">
            <el-table-column prop="id" label="编号" width="130"></el-table-column>
            <el-table-column prop="bookName" label="图书名称" width="130"></el-table-column>
            <el-table-column prop="finishStatus" label="完成状态" width="130">
                <template slot-scope="scope">
                    <span v-if="scope.row.finishStatus==0">未完成</span>
                    <span v-if="scope.row.finishStatus==1">已完成</span>
                </template>
            </el-table-column>
            <el-table-column label="创建时间" width="130">
                <template slot-scope="scope">
                    {{scope.row.createTime | datefmt('YYYY/MM/DD')}}
                </template>
            </el-table-column>
            <el-table-column label="计划盘点时间" width="130">
                <template slot-scope="scope">
                    {{scope.row.inventoryTime | datefmt('YYYY/MM/DD')}}
                </template>
            </el-table-column>
            <el-table-column label="操作" width="130">
                <template slot-scope="scope">
                    <el-button @click="getCode(scope.row.code)">
                        盘点
                    </el-button>
                </template>
            </el-table-column>
        </el-table>

        <el-dialog title="盘点" :visible.sync="dialogFormVisible">
            <el-form :model="inventoryRecord" ref="form">
                <el-form-item label="实际盘点数量" prop="inventoryNum">
                    <el-input v-model="inventoryRecord.inventoryNum" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="clearFrom">取 消</el-button>
                <el-button type="primary" @click="makeInventoryRecord">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    export default {
        name: "getInventoryTaskByNoFinish",
        data(){
            return{
                inventoryTask:[],
                dialogFormVisible: false,
                inventoryRecord:{
                    inventoryNum:'',
                    inventoryTaskCode:''
                }

            }
        },
        methods:{
            getInventoryTaskByNoFinish:function () {
                this.$http.post('/getInventoryTaskByNoFinish').then((res)=>{
                  if (res.data.success){
                    this.inventoryTask=res.data.result.tbInventoryTasks;
                  } else {
                    this.$message.error(res.data.message)
                  }
                })
            },
            getCode:function(code){
                this.inventoryRecord.inventoryTaskCode=code;
                this.dialogFormVisible = true
            },
            clearFrom:function () {
                this.dialogFormVisible = false
                this.$refs['form'].resetFields();
            },
            makeInventoryRecord:function () {
              var staffMember = JSON.parse(window.sessionStorage.getItem('tbStaffMember'))
                var staffMemberCode=staffMember.code;
                this.$http.post('/makeInventoryRecord?inventoryNum='+this.inventoryRecord.inventoryNum+'&staffMemberCode='+staffMemberCode+'&inventoryTaskCode='+this.inventoryRecord.inventoryTaskCode).then((res)=>{
                    if(res.data.success){
                        this.$message.success(res.data.message)
                        this.dialogFormVisible = false
                        this.$refs['form'].resetFields();
                    }else {
                        this.$message.error(res.data.message)
                    }
                })
            }
        },
        mounted() {
            this.getInventoryTaskByNoFinish();
        }
    }
</script>

<style scoped>

</style>
